define(function(require, exports, module) {
	var $=require('zepto');
	var Swipe=require('core/hhSwipe');
	function SwipeUtil() {}
	module.exports = SwipeUtil;
	SwipeUtil.prototype.init = function(obj) {
		var parentId=obj.parentId;
		var chooseId=obj.chooseId;
		var swipeId=obj.swipeId;
		var imgarr=obj.imgarr;
		var tpl=this.tpl(chooseId,swipeId,imgarr);
		document.getElementById(parentId).innerHTML=tpl;
		var elem = document.getElementById(swipeId);
		window.mySwipe = Swipe(elem, {
			startSlide:0,
			auto: 3000, 
			continuous: true,
			disableScroll:false,
			callback: function(_index, element) {
				var myParents=document.getElementById(chooseId);
				for(var i=0;i<myParents.children.length;i++){
					if(i==_index){
						myParents.children[i].className="choose";
					}else{
						myParents.children[i].className="choose_touch";
					}
				}
			}
		});
	}
	SwipeUtil.prototype.tpl= function(chooseId,swipeId,imgarr) {
		var tpl='';
		tpl+=this.createChoose(chooseId,imgarr);
		tpl+=this.createSwipe(swipeId,imgarr);
		return tpl;
	}
	SwipeUtil.prototype.createChoose= function(id,imgarr) {
		var tpl='<div id="recomchoose"><div class="recomBg"></div>';
		tpl+='<div id="'+id+'">';
		for(var i=0;i<imgarr.length;i++){
			if(i==0){
				tpl+='<div class="choose"></div>';
			}else{
				tpl+='<div class="choose_touch"></div>';
			}
		}
		tpl+='</div></div>';
		return tpl;
	}
	SwipeUtil.prototype.createSwipe= function(id,imgarr) {
		var tpl='<div id="'+id+'" class="swipe"><div class="swipe-wrap">';
		for(var i=0;i<imgarr.length;i++){
			tpl+='<div><img src="'+imgarr[i]+'"></div>';
		}
		tpl+='</div></div>';
		return tpl;
	}
	
});